namespace NFTRedit
{
    using System;
    using System.Drawing;

    [Serializable]
    public class Character
    {
        private static Bitmap backDot;
        private static Color backgroundColor = Color.FromArgb(0, 0xef, 0xde, 0xc6);
        private static Bitmap foreDot = new Bitmap(1, 1);
        private static Color foregroundColor = Color.FromArgb(0xff, 0, 0, 0);
        private ushort mCode;
        private char mGlyph;
        private byte mHeight;
        private byte mLetterWidth;
        private byte mOffsetX;
        private Bitmap mTile;
        private byte mWidth;

        static Character()
        {
            foreDot.SetPixel(0, 0, foregroundColor);
            backDot = new Bitmap(1, 1);
            backDot.SetPixel(0, 0, backgroundColor);
        }

        public Character(Bitmap pTile, ushort pCode, char pGlyph, byte pOffsetX, byte pLetterWidth, byte pWidth, byte pHeight)
        {
            this.mTile = pTile;
            this.mCode = pCode;
            this.mOffsetX = pOffsetX;
            this.mLetterWidth = pLetterWidth;
            this.mWidth = pWidth;
            this.mHeight = pHeight;
        }

        public ushort Code
        {
            get
            {
                return this.mCode;
            }
            set
            {
                this.mCode = value;
            }
        }

        public char Glyph
        {
            get
            {
                return this.mGlyph;
            }
            set
            {
                this.mGlyph = value;
            }
        }

        public byte Height
        {
            get
            {
                return this.mHeight;
            }
            set
            {
                this.mHeight = value;
            }
        }

        public short LetterWidth
        {
            get
            {
                return ((this.mLetterWidth > 0x7f) ? ((short) (this.mLetterWidth - 0x100)) : ((short) this.mLetterWidth));
            }
            set
            {
                this.mLetterWidth = (byte) value;
            }
        }

        public short OffsetX
        {
            get
            {
                return ((this.mOffsetX > 0x7f) ? ((short) (this.mOffsetX - 0x100)) : ((short) this.mOffsetX));
            }
            set
            {
                this.mOffsetX = (byte) value;
            }
        }

        public Bitmap Tile
        {
            get
            {
                return this.mTile;
            }
            set
            {
                this.mTile = value;
            }
        }

        public short Width
        {
            get
            {
                return ((this.mWidth > 0x7f) ? ((short) (this.mWidth - 0x100)) : ((short) this.mWidth));
            }
            set
            {
                this.mWidth = (byte) value;
            }
        }
    }
}

